package com.mvvm.start.base.app

import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.mvvm.start.base.utils.ActivityStackManager
import com.mvvm.start.base.utils.loge

/**
 * @功能: Activity生命周期监听
 * @User Lmy
 * @Creat 2021/10/28 4:22 下午
 * @Compony 永远相信美好的事情即将发生
 */
class ActivityLifecycleCallbacksImpl : Application.ActivityLifecycleCallbacks {
    private val TAG = "ActivityLifecycle"
    override fun onActivityCreated(activity: Activity, bundle: Bundle?) {
        ActivityStackManager.addActivityToStack(activity)
        "${activity.javaClass.simpleName} --> onActivityCreated".loge(TAG)
    }

    override fun onActivityStarted(activity: Activity) {
        "${activity.javaClass.simpleName} --> onActivityStarted".loge(TAG)

    }

    override fun onActivityResumed(activity: Activity) {
        "${activity.javaClass.simpleName} --> onActivityResumed".loge(TAG)

    }

    override fun onActivityPaused(activity: Activity) {
        "${activity.javaClass.simpleName} --> onActivityPaused".loge(TAG)

    }

    override fun onActivityStopped(activity: Activity) {
        "${activity.javaClass.simpleName} --> onActivityStopped".loge(TAG)

    }

    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
        "${activity.javaClass.simpleName} --> onActivitySaveInstanceState".loge(TAG)
    }

    override fun onActivityDestroyed(activity: Activity) {
        ActivityStackManager.popActivityToStack(activity)
        "${activity.javaClass.simpleName} --> onActivityDestroyed".loge(TAG)
    }
}